package vfs.common;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author aspr0
 *         Date: 21.04.12
 *         Time: 19:27
 */
public class Regex
{
    public static boolean stringMatchesMask(String stringToCheck, String checkMask, boolean caseInsensitive)
    {
        int flags = caseInsensitive ? Pattern.CASE_INSENSITIVE : 0;
        Pattern checkMaskPattern = Pattern.compile(checkMask, flags);
        return checkMaskPattern.matcher(stringToCheck).matches();
    }

    public static Matcher getMatcherStringMask(String stringToCheck, String checkMask, boolean caseInsensitive)
    {
        int flags = caseInsensitive ? Pattern.CASE_INSENSITIVE : 0;
        Pattern checkMaskPattern = Pattern.compile(checkMask, flags);
        return checkMaskPattern.matcher(stringToCheck);
    }
}
